package example;

import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import net.sf.hibernate.cfg.Configuration;
import net.sf.hibernate.HibernateException;
import my.com.sunway.bean.*;
import my.com.sunway.util.*;
import java.text.*;
import java.util.*;
import org.apache.log4j.*;

/**
 * @author Deepak Kumar
 *
 * http://www.roseindia.net
 * Hibernate example to inset data into Contact table
 */
public class InsertF0911 {
 static Logger logger = Logger.getLogger(InsertExample.class);

 public static void main(String[] args) {
  Session session = null;
  
  try{
   // This step will read hibernate.cfg.xml and prepare hibernate for use
   java.util.Date date = new java.util.Date();
   SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
   
   session = HibernateUtil.currentSession();
   //System.out.println("Configuration = "+configuration);   
   //Create new instance of Contact and set values in it by reading them from form object
   logger.info("Inserting Record");   
   
   F0911 accountLedger = new F0911();
   //accountLedger.setAbalph("user_"+sdf.format(date));
   logger.info("F0911 = "+accountLedger);
   
   session.save(accountLedger);
   logger.info("Done");
  }catch(Exception e){
   logger.error(e.getMessage());
  }finally{
   if(session!=null){
   try{
    // Actual contact insertion will happen at this step
    session.flush();
    session.close();
   }catch(Exception ex){
    logger.error("[error] "+ex);
   }
   }
  }
 }
}
